package com.ruoyi.pm.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pm.domain.ExcPortUpdateCondition;
import com.ruoyi.pm.service.IExcPortUpdateConditionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 请求返回订单修改限制条件Controller
 * 
 * @author ruoyi
 * @date 2022-04-12
 */
@RestController
@RequestMapping("/pm/excPortUpdateCondition")
public class ExcPortUpdateConditionController extends BaseController
{
    @Autowired
    private IExcPortUpdateConditionService excPortUpdateConditionService;

    /**
     * 查询请求返回订单修改限制条件列表
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExcPortUpdateCondition excPortUpdateCondition)
    {
        startPage();
        List<ExcPortUpdateCondition> list = excPortUpdateConditionService.selectExcPortUpdateConditionList(excPortUpdateCondition);
        return getDataTable(list);
    }

    /**
     * 导出请求返回订单修改限制条件列表
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:export')")
    @Log(title = "请求返回订单修改限制条件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExcPortUpdateCondition excPortUpdateCondition)
    {
        List<ExcPortUpdateCondition> list = excPortUpdateConditionService.selectExcPortUpdateConditionList(excPortUpdateCondition);
        ExcelUtil<ExcPortUpdateCondition> util = new ExcelUtil<ExcPortUpdateCondition>(ExcPortUpdateCondition.class);
        util.exportExcel(response, list, "请求返回订单修改限制条件数据");
    }

    /**
     * 获取请求返回订单修改限制条件详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(excPortUpdateConditionService.selectExcPortUpdateConditionById(id));
    }

    /**
     * 新增请求返回订单修改限制条件
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:add')")
    @Log(title = "请求返回订单修改限制条件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExcPortUpdateCondition excPortUpdateCondition)
    {
        return toAjax(excPortUpdateConditionService.insertExcPortUpdateCondition(excPortUpdateCondition));
    }

    /**
     * 修改请求返回订单修改限制条件
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:edit')")
    @Log(title = "请求返回订单修改限制条件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExcPortUpdateCondition excPortUpdateCondition)
    {
        return toAjax(excPortUpdateConditionService.updateExcPortUpdateCondition(excPortUpdateCondition));
    }

    /**
     * 删除请求返回订单修改限制条件
     */
    @PreAuthorize("@ss.hasPermi('pm:excPortUpdateCondition:remove')")
    @Log(title = "请求返回订单修改限制条件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(excPortUpdateConditionService.deleteExcPortUpdateConditionByIds(ids));
    }
}
